/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.WxAccessToken;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface WxAccessTokenMapper {
    /* @mbggenerated */
    @Delete({
        "delete from wx_access_token",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into wx_access_token (access_token, expires_in, ",
        "create_time)",
        "values (#{accessToken,jdbcType=VARCHAR}, #{expiresIn,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP})"
    })
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insert(WxAccessToken record);

    /* @mbggenerated */
    @InsertProvider(type=WxAccessTokenSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true,keyProperty="id")
    int insertSelective(WxAccessToken record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, access_token, expires_in, create_time",
        "from wx_access_token",
        "where expires_in >= TIMESTAMPDIFF(SECOND,create_time,now())"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="access_token", property="accessToken", jdbcType=JdbcType.VARCHAR),
        @Result(column="expires_in", property="expiresIn", jdbcType=JdbcType.INTEGER),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    WxAccessToken selectByPrimaryKey();

    /* @mbggenerated */
    @UpdateProvider(type=WxAccessTokenSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(WxAccessToken record);

    /* @mbggenerated */
    @Update({
        "update wx_access_token",
        "set access_token = #{accessToken,jdbcType=VARCHAR},",
          "expires_in = #{expiresIn,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(WxAccessToken record);
}